import { h, render } from 'vue'
import XtxConfirm from './xtx-confirm.vue'
// 准备div
const divVNode = h('div', { class: 'xtx-confirm-container' })
render(divVNode, document.body)
// 获取 DOM 节点
const div = divVNode.el
export default ({ title, text }) => {
  return new Promise((resolve, reject) => {
    const OkBtn = () => {
      render(null, div)
      resolve()
    }
    const NoBtn = () => {
      render(null, div)
      reject(new Error('点了取消'))
    }
    const ConfirmVNode = h(XtxConfirm, { title, text, OkBtn, NoBtn })
    render(ConfirmVNode, div)
  })
}
